package org.mch.swingm.core;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import javax.swing.JPanel;

import org.mch.comm.itf.IMLogger;
import org.mch.comm.loging.MComLogger;

public abstract class BasePanel extends JPanel {
	private static final long serialVersionUID = 4926610008670955502L;
	private IMLogger log;

	public BasePanel() {
		super();
		log = createLog();
		initMCH();
	}

	protected IMLogger createLog() {
		return new MComLogger(getClass());
	}

	protected void initMCH() {
	}

	protected String handleException(Throwable e) {
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		PrintStream ps = new PrintStream(os);
		e.printStackTrace(ps);
		e.printStackTrace();
		return os.toString();
	}

	public IMLogger log() {
		return log;
	}

}
